<?php
namespace app\common\model\mysql;

use think\Model;
class ModelBase extends Model{
	
	// 根据ID更新数据
	public function updateById($id,$data){
		$data['update_time'] = time();
		$where = [
			'id'=>$id,
		];
		return $this->where($where)->save($data);
	}

	//获取goodssku
	public function getNormalInIds($ids){
		$result = $this->where('status','=',config('status.mysql.normal'))
			->whereIn('id',$ids)
			->select();
	    //echo $this->getLastSql();exit;
		//dump($result);exit;
		return $result;
	}

	// 根据条件查询
	public function getByCondition($condition=[],$order=['id'=>'desc']){

		if(!$condition || !is_array($condition)){
			return false;
		}
		$result = $this->where($condition)
			->order($order)
			->select();
		//echo $this->getLastSql();exit;
		return $result;
	}

	//根据order_id更新mall_order表数据
	public function updateByOrderId($orderId,$data=[]){
		$data['pay_time'] = time();
		$data['end_time'] = time();
		$data['status'] = 2;
		$where = [
			'order_id' => $orderId,
		];
		//return 1;
		return $this->where($where)->save($data);
	}
}